package matrics;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.spell.LuceneDictionary;

public class MapTermsToInteger {
	public static HashMap<String, Integer> getTermsToIntger(IndexReader iReader)
			throws IOException {
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		// BufferedReader br = new BufferedReader(new FileReader(new
		// File("/local/joofeit/Freq/cfNew")));
		// String line = "";
		// int counter = 0;
		// while ((line = br.readLine()) != null) {
		// map.put(line.split(" ")[0], counter);
		// counter++;
		// }
		int counter = 0;
		LuceneDictionary ld = new LuceneDictionary(iReader, "lemma");
		Iterator<String> it = ld.getWordsIterator();
		while (it.hasNext()) {
			String s = it.next();
			map.put(s, counter);
			counter++;

		}

		return map;
	}

}
